﻿using System.Data.Entity;
using LabNet.Server.Domain;

namespace LabNet.Server.Configuration
{
    public class UserConfiguration
    {
        public static void Map(DbModelBuilder modelBuilder)
        {
            modelBuilder
                .Entity<User>()
                .ToTable("User");


            modelBuilder
                .Entity<User>()
                .HasMany(o => o.Logins)
                .WithRequired(o => o.User)
                .HasForeignKey(o => o.UserId);

            modelBuilder
                .Entity<User>()
                .HasMany(o => o.Claims)
                .WithRequired(o => o.User)
                .HasForeignKey(o => o.UserId);

            modelBuilder
                .Entity<User>()
                .HasMany(o => o.Roles)
                .WithRequired(o => o.User)
                .HasForeignKey(o => o.UserId);

            modelBuilder
               .Entity<User>()
               .HasMany(o => o.Groups)
               .WithRequired(o => o.User)
               .HasForeignKey(o => o.UserId);
        }
    }
}
